#include <stdio.h>

int max(int a[], int n) {
    int maxIdx = 0;
    for (int i = 1; i < n; i++) {
        if (a[i] > a[maxIdx]) {
            maxIdx = i;
        }
    }
    return maxIdx;
}

int main() {
    int a[] = {1, 5, 9, 10, 3, 5, 7, 9};
    int n = sizeof(a) / sizeof(int);
    int maxIdx = max(a, n);
    printf("maxIdx = %d, max = %d\n", maxIdx, a[maxIdx]);
    return 0;
}
